// 2. 导入
import { createRouter, createWebHashHistory } from 'vue-router'

// 导入一级目录
import Find from '@/views/Find.vue'
import Select from '@/views/Select.vue'
import Sort from '@/views/Sort.vue'
import _404 from '@/views/_404.vue'

// 导入二级目录
import Recommend from '../views/Recommend.vue'
import Toplist from '../views/Toplist.vue'
import Operalist from '../views/Operalist.vue'

// 3. 创建
const router = createRouter({
  history: createWebHashHistory(),
  routes: [{
    // 重定向
    path: '/',
    redirect: '/find/recommend' // 修改为推荐
  }, {
    path: '/find',
    component: Find,
    // Find 这个组件下的一级目录 （相对于全局是二级）
    // 因为是孩子 所以默认是当前目录下的子目录 不用加 /
    children: [{
      path: 'recommend',
      component: Recommend
    }, {
      path: 'toplist',
      component: Toplist
    }, {
      path: 'operalist',
      component: Operalist
    }]
  }, {
    path: '/select',
    component: Select
  }, {
    name: 'Sort',
    path: '/sort',
    component: Sort
  }, {
    path: '/:pathMatch(.*)*',
    component: _404
  }]
})

// 默认导出
export default router